package com.fan.teamer.service;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import org.springframework.transaction.annotation.Transactional;

import com.fan.teamer.model.dao.MessageDao;
import com.fan.teamer.model.domain.Message;

@Named("messageService")
@Transactional(readOnly = true)
public class MessageServiceImpl implements MessageService {

	@Inject
	@Named("messageDao")
	private MessageDao messageDao;

	public MessageDao getMessageDao() {
		return messageDao;
	}

	public void setMessageDao(MessageDao messageDao) {
		this.messageDao = messageDao;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public List getList() {
		return messageDao.getAllMessages();
	}

	@Override
	public int getColumnsSize() {
		return messageDao.getColumnNames().size();
	}

	@Override
	public Object copy(Object obj) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Message getMessage(int id) {
		return messageDao.getMessage(id);
	}

	@Override
	public List<Message> getAllMessages() {
		return messageDao.getAllMessages();
	}

	@Override
	public int getSize() {
		return messageDao.getSize();
	}

	@Override
	@Transactional(readOnly = false)
	public void addMessage(Message message) {
		messageDao.addMessage(message);
	}

	@Override
	@Transactional(readOnly = false)
	public void updateStock(Message message) {
		messageDao.updateStock(message);
	}

	@Override
	@Transactional(readOnly = false)
	public void deleteMessage(Message message) {
		messageDao.deleteMessage(message);
	}

	@Override
	public boolean hasMessage(int id) {
		return messageDao.hasMessage(id);
	}

	@Override
	public List<String> getColumnNames() {
		return messageDao.getColumnNames();
	}

}
